#include "tsqlrelationaldelegate.h"

TSqlRelationalDelegate::TSqlRelationalDelegate(QObject *parent)
    : QSqlRelationalDelegate(parent)
{

}

void TSqlRelationalDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QColor alternateColor;
    if (index.row() % 2 == 1) {
        // 设置交替行的背景色
        alternateColor = option.palette.color(QPalette::Base);
    }
    else
    {
        alternateColor = option.palette.color(QPalette::AlternateBase);
    }
    // qDebug()<<"alternateColor"<<alternateColor.name();
    painter->fillRect(option.rect, alternateColor);

    QStyledItemDelegate::paint(painter, option, index);
}
